package com.niit.service.impl;

import com.niit.dao.ProductMapper;
import com.niit.pojo.Product;
import com.niit.service.ProductService;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductServiceImpl implements ProductService {

    private final ProductMapper productMapper;

    public ProductServiceImpl(ProductMapper productMapper) {
        this.productMapper = productMapper;
    }

    @Override
    public int addProduct(Product product) {
        return productMapper.insertProduct(product);
    }

    @Override
    public int deleteProductById(int pid) {
        return productMapper.deleteProductById(pid);
    }

    @Override
    public Product getProductById(int pid) {
        return productMapper.queryProductById(pid);
    }
    @Override
    public int updateProduct(Product product) {
        return productMapper.updateProduct(product);
    }

    @Override
    public List<Product> getAllProducts() {
        return null;
    }

    @Override
    public List<Product> queryProduct(Product product) {
        List<Product> queriedProduct = productMapper.queryProduct(product);
        return queriedProduct;
    }

}
